<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="org.osgi.framework.*"%>
<%@ page import="com.gzgi.framework.*"%>
<%@ page import="com.gzgi.framework.util.*"%>
<%@ page import="com.gzgi.framework.context.*"%>
<%@ page import="com.gzgi.framework.config.*"%>
<%@ page import="com.gzgi.workflow.service.*"%>
<%
        SessionContainer.getContainer().reloadSessionFactory();
        EntityService entityService = EntityContainer.getContainer().getEntityService();
        Map dataMap = new HashMap();
        dataMap.put("appId", new Long(100));
		dataMap.put("key", "key_"+UUID32.getUUID());
		dataMap.put("title", "广州");
		dataMap.put("status", new Integer(0));
		dataMap.put("wfStatus", new Integer(0));
		dataMap.put("deleteFlag", new Integer(0));
		dataMap.put("actorId", "admin");

        Map nodeInstances = new HashMap();
		for(int i=0;i<10;i++){
			Map map = new HashMap();
            map.put("nodeId", new Long(120));
			map.put("name", "name_"+i);
			map.put("integerValue", new Integer(i*100));
			map.put("formInstance", dataMap);
			nodeInstances.put("name_"+i, map);
		}

        dataMap.put("nodeInstances", nodeInstances);
		
		entityService.save("formInstance", dataMap);
        
        org.hibernate.Session s = null;
		try {
			String hsql = " select a from formInstance as a where a.title like '%广州%' ";
		    s = SessionContainer.getContainer().getSession();
			List list  = entityService.getList(s, hsql, null);
			out.println("rows size:"+list.size());		
			Iterator iterator = list.iterator();
			while(iterator.hasNext()){
				Map mx = (Map)iterator.next();
				out.println("<br>----------------------------------------------------------------------------");
				out.println("<br>"+mx.get("key"));
				out.println("<br>{");
				Map nx = (Map)mx.get("nodeInstances");
				if(nx != null){
				      Iterator iter = nx.keySet().iterator();
			          while(iter.hasNext()){
						  String name = (String)iter.next();
						  if(!name.equals("formInstance")){
						       Map xx = (Map)nx.get(name);
                               Iterator it = xx.keySet().iterator();
			                   while(it.hasNext()){
						         String key = (String)it.next();
								 if(!key.equals("formInstance")){
                                     out.println(key+"="+xx.get(key));
								 }
							   }
						  }
					  }
				}
				out.println("}");
			}
		} finally {
			SessionContainer.getContainer().release();
		}
        
 %>